<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache"> 
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> 
    <meta HTTP-EQUIV="expires" CONTENT="0"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>VectorBaseDB</title>

    <link href="css/image.list.css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script>
	function upFile () {
        document.getElementById("inputFileAgent").value = document.getElementById("file").value;
        var fileObj = document.getElementById("file").files[0]
        var formData = new FormData()
        formData.append("file", fileObj);
		
		var xhr = new XMLHttpRequest();
		
        $.ajax({
            url: "/static/vdb/search",
            data: formData,
            type: "POST",
            contentType: false,
            processData: false,
            success: function (res) {
            	showData(res)
            	$('#file').val('')
            }
        })
        
    }
	function showData(msg){
		var jsonData=jQuery.parseJSON(msg)
		var ori_url = jsonData["ori_url"]
		$("#tabinfo1").html("<ul class=\"imgList clearfix\"><li><img src=images/" + ori_url + "></li>")
		var data = jsonData["sim_url"]
		var str = "<ul class=\"imgList clearfix\">"
		for (var i = 0, l = data.length; i < l; i++){
                    str = str + "<li><div class='imgWrapper'><img src=" + data[i]["imageurl"] + "></div><p>score: "+data[i]["score"]+"</p></li>";
		}
		str = str + "</ul>"
		$("#tabinfo2").html(str)
	}
	</script>
  </head>

	
<body>
	<h1 class="page-header">The Result Display Platform of Vearch </h1>
	<input type="file"  style="display:none"  name="pic"  id="file" accept="image/*" onchange="upFile()">
        <input type="text" value="please choose one picture..." disabled id="inputFileAgent" />
        <input type="button" onclick="document.getElementById('file').click()" value="Browse..." />
	<table class="table table-striped" id="tabinfo1"></table>
	<div class="table-responsive">
		<table class="table table-striped" id="tabinfo2"></table>
	</div>
</body>
</html>
